// Fill out your copyright notice in the Description page of Project Settings.


#include "C14TestActor.h"

#include <GoogleTest/include/gmock/gmock-matchers.h>

#include "SNodePanel.h"
#include "Kismet/KismetStringLibrary.h"
#include "UE5TricksProject/TricksDefineType/C14DefineType.h"

// Sets default values
AC14TestActor::AC14TestActor()
{
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

}

// Called when the game starts or when spawned
void AC14TestActor::BeginPlay()
{
	Super::BeginPlay();
	PrintMessageToScreen();
	TestForeachIterator();
}

// Called every frame
void AC14TestActor::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
}

void AC14TestActor::PrintMessageToScreen()
{
	G_PrintLambda(GetWorld(), MessageContent);
}

void AC14TestActor::TestForeachIterator()
{
	TArray<int> PrintArray = {4,8,12,18,13,3};
	UWorld* CurWorld = GetWorld();
	auto _PrintFunction = [CurWorld](auto & a)
	{
		UKismetSystemLibrary::PrintString(CurWorld, UKismetStringLibrary::Conv_IntToString(a));
	};
	for (auto ChildNumber : PrintArray) {_PrintFunction(ChildNumber);};
	
	int32 AutoValue = GetAutoTypeValue(1000000); 
	_PrintFunction(AutoValue);

	AliasTestStruct<int32> TestStruct;
	TestStruct.t = 246810;
	TestStruct.u = FAliasStruct();
	_PrintFunction(TestStruct.t);
	AutoValue = (int32)TestStruct.u.AliasFloatValue;
	_PrintFunction((AutoValue));
	UKismetSystemLibrary::PrintString(CurWorld, UKismetStringLibrary::Conv_NameToString(TestStruct.u.AliasName));

	constexpr int32 a = 100;
	constexpr int32 b = 35;
	constexpr int32 result = GetMaxValue(a, b);
	_PrintFunction(result);

	auto LambdaPairFucntion = [](const float Left, const float Right)
	{
		return TTuple<float, float>(Left, Right); 
	};

	const auto[Left, Right] = LambdaPairFucntion(3.5f, 4.5f);
	UKismetSystemLibrary::PrintString(GetWorld(), UKismetStringLibrary::Conv_FloatToString(Left));
	UKismetSystemLibrary::PrintString(GetWorld(), UKismetStringLibrary::Conv_FloatToString(Right));

	TMap<int32, FString> StructBind = {{1, "Hello"}, {2, "World"}};
	for (const auto&[LeftChild, RightChild] : StructBind)
	{
		_PrintFunction(LeftChild);
		UKismetSystemLibrary::PrintString(GetWorld(), RightChild);
	}

	UKismetSystemLibrary::PrintString(GetWorld(), UKismetStringLibrary::Conv_FloatToString(RootTestNS::SubFirstTestNS::LastNameSpace::TestNSValue));
}

auto* AC14TestActor::DecltypeReturnValue()
{
	return GetWorld();
}
